<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>INSPINIA | Login</title>
    <base th:href="@{/}">
    <link href="inspinia/css/bootstrap.min.css" rel="stylesheet">
    <link href="inspinia/font-awesome/css/font-awesome.css" rel="stylesheet">

    <link href="inspinia/css/animate.css" rel="stylesheet">
    <link href="inspinia/css/style.css" rel="stylesheet">
    <link type="text/css" rel="stylesheet" href="inspinia/css/plugins/bootstrap-dialog/bootstrap-dialog.min.css" />

</head>

<body class="gray-bg">

<div class="middle-box text-center loginscreen animated fadeInDown">
    <div>
        <div>

            <h1 class="logo-name">IN+</h1>

        </div>
        <h3>欢迎!</h3>
        <p>SpringBoot+mybatis +BootStrap3+thymeleaf 学习.
            <!--Continually expanded and constantly improved Inspinia Admin Them (IN+)-->
        </p>
        <p>登录</p>
        <form class="m-t" role="form" action="#">
            <div class="form-group">
                <input type="text" class="form-control" id="name" name="name" placeholder="用户名" required="">
            </div>
            <div class="form-group">
                <input type="password"  id="password" name="password" class="form-control" placeholder="密码" required="">
            </div>
            <button id="btnLogin" type="button" class="btn btn-primary block full-width m-b">Login</button>

            <a href="#"><small>忘记密码?</small></a>
            <p class="text-muted text-center"><small>没有账号?</small></p>
            <a class="btn btn-sm btn-white btn-block" href="register.html">创建一个账号</a>
        </form>
        <p class="m-t"> <small>Inspinia we app framework base on Bootstrap 3 &copy; 2020</small> </p>
    </div>
</div>
<a style="display:none;" id="lnktz" th:href="${#httpServletRequest.getContextPath()}+'/user/user_list'">加载中。。。</a>
<!-- Mainly scripts -->
<script src="inspinia/js/jquery-3.1.1.min.js"></script>
<script src="inspinia/js/popper.min.js"></script>
<script src="inspinia/js/bootstrap.js"></script>

<!--bootstrap-dialog start-->
<script type="text/javascript" src="inspinia/js/plugins/bootstrap-dialog/bootstrap-dialog.min.js" ></script>
<!--bootstrap-dialog end-->

<!-- 该通用脚本放在最后 -->
<script type="text/javascript" src="inspinia/js/Common.js" ></script>
<script>
    $(document).ready(function () {
        $("#btnLogin").click(function(){

            if  ($('#name').val()=="") {
                alert("用户名不能为空！", BootstrapDialog.TYPE_DANGER);
                return;
            }
            if  ($('#password').val()==""){
                alert("密码不能为空！", BootstrapDialog.TYPE_DANGER);
                return;
            }

            $.ajax({
                // 提交数据的类型 POST GET
                type: "Get",
                // 提交的网址
                url: "user/login",
                // 提交的数据
                data: {
                    name: $('#name').val(),
                    password: $('#password').val(),
                },
                // 返回数据的格式
                datatype: "json",
                // 在请求之前调用的函数
                // beforeSend: xmlBeforeSend,
                // 成功返回之后调用的函数
                success: function (data) {
                    //$.fn.jqLoading("destroy");

                    if (data != null && data.result == "success") {
                        document.getElementById("lnktz").click();
                    } else {
                        alert(data.message, BootstrapDialog.TYPE_DANGER);
                    }
                }//,
                // 调用出错执行的函数
                //error: xmlError
            });
        });


    });

</script>

</body>

</html>
